package icdwkang;


import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.EventQueue;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JScrollPane;
import javax.swing.JTabbedPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.border.EmptyBorder;

import B_DAO.Emp_DAO;

public class DogMain extends JFrame {

	private JPanel contentPane;
	private JTable dogTable;		// 유기견 테이블
	private JTable empTable;		// 직원 테이블
	private JTable adoTable;		// 입양자 테이블
	private JTextField Id;			// 로그인 화면에서 아이디 입력 필드
	private JPasswordField pwd;		// 로그인 화면에서 비밀번호 입력 필드
	private JButton loginBtn; 		// 로그인 화면에서 로그인 버튼
	private JButton regBtn; 		// 로그인 화면에서 회원 가입 버튼
	private JTextField searchBtn;	// 로그아웃 화면에서 검색 버튼
	private JButton logoutBtn;		// 로그아웃 화면에서 로그아웃 버튼
	private JLabel txtInfo;			// 로그아웃 화면에서 사용자 이름이나 정보가 표시되는 라벨
	Emp_DAO edao = new Emp_DAO();
	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					DogMain frame = new DogMain();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}
	
	
	/*
	 * 기본 생성자
	 */
	public DogMain(){
		initialize();
	}
	
	/*
	 * Create the frame.
	 * 
	 * 기본 판넬 구조
	 * contentPane	- headpanel ; 윗 부분 개그림 레이블이 들어가는 판넬
	 * 				- memberPanel ; 로그인 폼이 들어가는 판넬
	 * 							- loginPanel ; 로그인 화면이 표시되는 판넬
	 * 							- logoutPanel ; 로그인 후의 화면이 표시되는 판넬
	 * 				- mainPanel	; 아랫 부분이 주요 내용들이 표시되는 판넬 cardLayout으로 구성
	 * 							- tabPanel ; 각 탭들이 들어가는 판넬
	 * 							- indexPanel ; 프로그램 최초 구동시 표시되는 판넬
	 * 							- myPanel ; 회원 정보 수정 및 삭제를 표시하는 판넬
	 * 							- adminpanel ; 관리자용 관리 페이지가 표시되는 판넬
	 */				
	private void initialize() {
		setTitle("유기견 관리 프로그램");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 1024, 768);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		contentPane.setLayout(new BorderLayout(0, 0));
		setContentPane(contentPane);
		
		JPanel headPanel = new JPanel();
		headPanel.setMaximumSize(new Dimension(32767, 200));
		headPanel.setPreferredSize(new Dimension(10, 100));
		headPanel.setBackground(Color.LIGHT_GRAY);
		contentPane.add(headPanel, BorderLayout.NORTH);
		
		JPanel memberPanel = new JPanel();
		memberPanel.setMaximumSize(new Dimension(32767, 100));
		contentPane.add(memberPanel, BorderLayout.CENTER);
		memberPanel.setLayout(new CardLayout(0, 0));
		
		JPanel loginPanel = new JPanel();
		FlowLayout flowLayout = (FlowLayout) loginPanel.getLayout();
		flowLayout.setVgap(20);
		flowLayout.setHgap(20);
		flowLayout.setAlignment(FlowLayout.LEFT);
		memberPanel.add(loginPanel, "loginPanel");
		
		JLabel txtId = new JLabel("아이디");
		loginPanel.add(txtId);
		
		Id = new JTextField();
		loginPanel.add(Id);
		Id.setColumns(10);
		
		JLabel txtBlank1 = new JLabel("    ");
		loginPanel.add(txtBlank1);
		
		JLabel txtPwd = new JLabel("비밀번호");
		loginPanel.add(txtPwd);
		
		pwd = new JPasswordField();
		loginPanel.add(pwd);
		pwd.setColumns(10);
		
		JLabel txtBlank2 = new JLabel("    ");
		loginPanel.add(txtBlank2);
		
		loginBtn = new JButton("로그인");
		loginPanel.add(loginBtn);
		
		JLabel txtBlank3 = new JLabel("    ");
		loginPanel.add(txtBlank3);
		
		regBtn = new JButton("회원가입");
		loginPanel.add(regBtn);
		
		JPanel logoutPanel = new JPanel();
		FlowLayout flowLayout_1 = (FlowLayout) logoutPanel.getLayout();
		flowLayout_1.setVgap(20);
		flowLayout_1.setHgap(20);
		flowLayout_1.setAlignment(FlowLayout.LEFT);
		memberPanel.add(logoutPanel, "logoutPanel");
		
		txtInfo = new JLabel("000님 로그인 하셨습니다.");
		logoutPanel.add(txtInfo);
		
		logoutBtn = new JButton("로그아웃");
		logoutPanel.add(logoutBtn);
		
		JLabel txtSearch = new JLabel("검색");
		logoutPanel.add(txtSearch);
		
		searchBtn = new JTextField();
		logoutPanel.add(searchBtn);
		searchBtn.setColumns(10);
		
		
		
		

		/*
		 * 메인 부분의 표시 패널
		 */
		JPanel mainPanel = new JPanel();
		mainPanel.setPreferredSize(new Dimension(10, 550));
		contentPane.add(mainPanel, BorderLayout.SOUTH);
		mainPanel.setLayout(new CardLayout(0, 0));
		
		

		/*
		 * 탭 패널 설정
		 */
		JTabbedPane tabPanel = new JTabbedPane(JTabbedPane.TOP);
		mainPanel.add(tabPanel, "tabPanel");
		
		
		

		/*
		 * 유기견 관리 패널
		 */
		JPanel dogPanel = new JPanel();
		tabPanel.addTab("DOG", null, dogPanel, null);
		dogPanel.setLayout(new BorderLayout(0, 0));
		
		JScrollPane dogScroll = new JScrollPane();
		dogScroll.setPreferredSize(new Dimension(2, 200));
		dogPanel.add(dogScroll, BorderLayout.NORTH);
		
		dogTable = new JTable();
		dogTable.setPreferredScrollableViewportSize(new Dimension(32767, 32767));
		dogTable.setPreferredSize(new Dimension(2, 200));
		dogScroll.setViewportView(dogTable);
		
		JPanel dogDetail = new JPanel();
		dogDetail.setPreferredSize(new Dimension(490, 10));
		dogPanel.add(dogDetail, BorderLayout.WEST);
		
		JPanel dogMenu = new JPanel();
		dogMenu.setPreferredSize(new Dimension(500, 10));
		dogPanel.add(dogMenu, BorderLayout.EAST);
		
	
		/*
		 * 직원 관리 패널
		 */
		JPanel empPanel = new JPanel();
		tabPanel.addTab("EMPLOYEE", null, empPanel, null);
		empPanel.setLayout(new BorderLayout(0, 0));
		
		JScrollPane empScroll = new JScrollPane();
		empScroll.setPreferredSize(new Dimension(2, 200));
		empPanel.add(empScroll, BorderLayout.NORTH);
		
		empTable = new JTable();
		empTable.setPreferredSize(new Dimension(0, 200));
		empScroll.setViewportView(empTable);
		
		JPanel empDetail = new JPanel();
		empDetail.setPreferredSize(new Dimension(490, 10));
		empPanel.add(empDetail, BorderLayout.WEST);
		
		JPanel empMenu = new JPanel();
		empMenu.setPreferredSize(new Dimension(500, 10));
		empPanel.add(empMenu, BorderLayout.EAST);

		

		/*
		 * 입양자 관리 패널
		 */
		JPanel adoPenel = new JPanel();
		tabPanel.addTab("ADOPTER", null, adoPenel, null);
		adoPenel.setLayout(new BorderLayout(0, 0));
		
		JScrollPane adoScroll = new JScrollPane();
		adoScroll.setPreferredSize(new Dimension(2, 200));
		adoPenel.add(adoScroll, BorderLayout.NORTH);
		
		adoTable = new JTable();
		adoTable.setPreferredSize(new Dimension(0, 200));
		adoScroll.setViewportView(adoTable);
		
		JPanel adoDetail = new JPanel();
		adoDetail.setPreferredSize(new Dimension(490, 10));
		adoPenel.add(adoDetail, BorderLayout.WEST);
		
		JPanel adoMenu = new JPanel();
		adoMenu.setPreferredSize(new Dimension(500, 10));
		adoPenel.add(adoMenu, BorderLayout.EAST);

		
		
		/*
		 * 게시판 탭 패널
		 * 추후 구현 예정
		 */
		JPanel boardPenel = new JPanel();
		tabPanel.addTab("BOARD", null, boardPenel, null);
		
		
		
		
		/*
		 * 프로그램 최초 실행시 표시되는 패널
		 */
		JPanel indexPanel = new JPanel();
		mainPanel.add(indexPanel, "indexPanel");
		indexPanel.setLayout(new BorderLayout(0, 0));
		
		JPanel indexDog = new JPanel();
		indexPanel.add(indexDog, BorderLayout.WEST);
		
		JPanel indexBbs = new JPanel();
		indexPanel.add(indexBbs, BorderLayout.EAST);
		
		
		
		
		/*
		 * 회원 정보 표시 패널 
		 */
		JPanel myPanel = new JPanel();
		mainPanel.add(myPanel, "myPanel");
		
		
		
		
		/*
		 * 관리자 페이지 패널
		 */
		JPanel adminPanel = new JPanel();
		mainPanel.add(adminPanel, "adminPanel");
	}

}
